// http://localhost:3001
import axios from "axios";
export const host:string = `http://localhost:3001`;


// 处理图片的接口
export const uploadPhoto = (data={})=>{
    return axios.post(`${host}/api/photo/upload`,data,{headers:{ 'Content-Type': 'multipart/form-data'}})
    .then(response => response.data)
}
export const removePhoto = (data={})=>{
    return axios.post(`${host}/api/photo/delete`,data).then(response => response.data)
}


// 封装接口
export const register = (data={})=> {
    return axios.post(`${host}/api/user/register`,data).then(response => response.data)
}
export const login = (data={})=> {
    return axios.post(`${host}/api/user/login`,data).then(response => response.data)
}
export const logined = (data={})=> {
    return axios.post(`${host}/api/user/isLogined`,data).then(response => response.data)
}

// 轮播图列表
export const bannerList = ()=> {
    return axios.get(`${host}/api/banner/list`).then(response => response.data)
}

// 文章列表 http://localhost:3001/api/article/items 
export const articleItems = (data={})=> {
    return axios.post(`${host}/api/article/items`,data).then(response => response.data)
}

// 文章详情 
export const articleDetail = (data={})=> {
    return axios.post(`${host}/api/article/detail`,data).then(response => response.data)
}

// 搜索文章
export const articleSearch = (data={})=> {
    return axios.post(`${host}/api/article/search`,data).then(response => response.data)
}
// 按分类获取文章列表
export const articleList = (data={})=> {
    return axios.post(`${host}/api/article/list`,data).then(response => response.data)
}

// 获取导航列表
export const cateList = ()=> {
    return axios.get(`${host}/api/cate/list`).then(response => response.data)
}